{
 "metadata": {
  "name": "",
  "signature": "sha256:0486cb265bed4606d5c7924f5bc114be875cca4197f33381aaa985a9b1599eb6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import torch\n",
      "import torch.nn as nn\n",
      "import torch.optim as optim\n",
      "import torch.utils.data as data\n",
      "import numpy as np\n",
      "import pandas as pd\n",
      "import cv2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def gaussian_weights_init(m):\n",
      "    classname = m.__class__.__name__\n",
      "    if classname.find('Conv') != -1:\n",
      "        m.weight.data.normal_(0.0, 0.0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "class FaceCNN(nn.Module):\n",
      "    def __init__(self):\n",
      "        super(FaceCNN, self).__init__()\n",
      "        \n",
      "        self.conv1 = nn.Sequential(\n",
      "            nn.Conv2d(in_channels=1, out_channels=64, kernel_size=3, stride=1, padding=1),\n",
      "            nn.BatchNorm2d(num_features=64),\n",
      "            nn.PReLU(),\n",
      "            nn.MaxPool2d(kernel_size=2, stride=2),\n",
      "        )\n",
      "        \n",
      "        self.conv2 = nn.Sequential(\n",
      "            nn.Conv2d(in_channels=64, out_channels=128, kernel_size=3, stride=1, padding=1),\n",
      "            nn.BatchNorm2d(num_features=128),\n",
      "            nn.PReLU(),\n",
      "            nn.MaxPool2d(kernel_size=2, stride=2),\n",
      "        )\n",
      "        \n",
      "        self.conv3 = nn.Sequential(\n",
      "            nn.Conv2d(128, 256, 3, 1, 1),\n",
      "            nn.BatchNorm2d(256),\n",
      "            nn.PReLU(),\n",
      "            nn.MaxPool2d(2, 2),\n",
      "        )\n",
      "        \n",
      "        #initialize\n",
      "        self.conv1.apply(gaussian_weights_init)\n",
      "        self.conv2.apply(gaussian_weights_init)\n",
      "        self.conv3.apply(gaussian_weights_init)\n",
      "        \n",
      "        self.fc = nn.Sequential(\n",
      "            nn.Dropout(p=0.2),\n",
      "            nn.Linear(in_features=256*6*6, out_features=4096),\n",
      "            nn.PReLU(),\n",
      "            nn.Dropout(p=0.5),\n",
      "            nn.Linear(in_features=4096, out_features=1024),\n",
      "            nn.PReLU(),\n",
      "            nn.Linear(1024, 256),\n",
      "            nn.PReLU(),\n",
      "            nn.Linear(256, 7),\n",
      "        )\n",
      "        \n",
      "    def forward(self, x):\n",
      "        out = self.conv1(x)\n",
      "        out = self.conv2(out)\n",
      "        out = self.conv3(out)\n",
      "        out = out.view(out.shape[0], -1)\n",
      "        out = self.fc(out)\n",
      "        return out"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def validate(model, dataset, batch_size):\n",
      "    dataset_loader = data.DataLoader(dataset, batch_size)\n",
      "    result, num =0, 0\n",
      "    for images, labels in dataset_loader:\n",
      "        images = images.cuda()\n",
      "        pred = model.forward(images)\n",
      "        pred = pred.cpu()\n",
      "        pred = np.argmax(pred.data.numpy(), axis=1)\n",
      "        labels = labels.data.numpy()\n",
      "        result += np.sum((pred==labels))\n",
      "        num += len(images)\n",
      "    acc = result / num\n",
      "    return acc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def train(train_dataset, val_dataset, batch_size, epoches, learning_rate, wt_decay):\n",
      "    gpus = [0]\n",
      "    train_load = data.DataLoader(train_dataset, batch_size)\n",
      "    model = FaceCNN()\n",
      "    model = torch.nn.DataParallel(model, device_ids=gpus).cuda()\n",
      "    loss_fuction = nn.CrossEntropyLoss()\n",
      "    optimizer = optim.Adam(model.parameters(), lr=learning_rate, weight_decay=wt_decay)\n",
      "    for epoch in range(epoches):\n",
      "        loss = 0\n",
      "        model.train()\n",
      "        for images, labels in train_load:\n",
      "            images = images.cuda()\n",
      "            labels = labels.cuda()\n",
      "            optimizer.zero_grad()\n",
      "            output = model.forward(images)\n",
      "            loss = loss_fuction(output, labels)\n",
      "            loss.backward()\n",
      "            optimizer.step()\n",
      "        print ('After {} epoches, the loss is: {}'.format((epoch+1), loss.item()))\n",
      "        if epoch % 5 == 0:\n",
      "            model.eval()\n",
      "            acc_train = validate(model, train_dataset, batch_size)\n",
      "            acc_val = validate(model, val_dataset, batch_size)\n",
      "            print ('After {} epoches, the train acc. is: {}'.format((epoch+1), acc_train))\n",
      "            print ('After {} epoches, the val acc. is: {}'.format((epoch+1), acc_val))\n",
      "    return model\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from FaceDataset import FaceDataset\n",
      "train_dataset = FaceDataset(r\"/media/root/515e7d3a-49ac-40be-ba58-fef9702d123c/work_record/\u4f5c\u4e1a3/face/train\")\n",
      "val_dataset = FaceDataset(r\"/media/root/515e7d3a-49ac-40be-ba58-fef9702d123c/work_record/\u4f5c\u4e1a3/face/val\")\n",
      "model = train(train_dataset, val_dataset, 128, 100, 0.1, 0)\n",
      "torch.save(model, 'model_final_100.pkl')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "After 1 epoches, the loss is: 343.0107116699219\n",
        "After 1 epoches, the train acc. is: 0.14916666666666667"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 1 epoches, the val acc. is: 0.14843915905712465\n",
        "After 2 epoches, the loss is: 33.68903732299805"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 3 epoches, the loss is: 52.081214904785156"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 4 epoches, the loss is: 14.31796646118164"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 5 epoches, the loss is: 11.905047416687012"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 6 epoches, the loss is: 18.883102416992188"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 6 epoches, the train acc. is: 0.08354166666666667"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 6 epoches, the val acc. is: 0.07942238267148015\n",
        "After 7 epoches, the loss is: 7.02323579788208"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 8 epoches, the loss is: 7.255063533782959"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 9 epoches, the loss is: 24.744768142700195"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 10 epoches, the loss is: 3.687321662902832"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 11 epoches, the loss is: 11527058432.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 11 epoches, the train acc. is: 0.015708333333333335"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 11 epoches, the val acc. is: 0.012529199405393926\n",
        "After 12 epoches, the loss is: 13574740.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 13 epoches, the loss is: 2145167.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 14 epoches, the loss is: 10776220.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 15 epoches, the loss is: 10531592.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 16 epoches, the loss is: 82001.7578125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 16 epoches, the train acc. is: 0.138625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 16 epoches, the val acc. is: 0.14419197281800808\n",
        "After 17 epoches, the loss is: 4690693.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 18 epoches, the loss is: 3906170.5"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 19 epoches, the loss is: 2021400.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 20 epoches, the loss is: 1194073.375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 21 epoches, the loss is: 1109652.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 21 epoches, the train acc. is: 0.17529166666666668"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 21 epoches, the val acc. is: 0.17455935442769166\n",
        "After 22 epoches, the loss is: 3124197.5"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 23 epoches, the loss is: 4805286.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 24 epoches, the loss is: 997288.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 25 epoches, the loss is: 137272.015625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 26 epoches, the loss is: 186532.515625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 26 epoches, the train acc. is: 0.17525"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 26 epoches, the val acc. is: 0.1726481206200892\n",
        "After 27 epoches, the loss is: 102630.28125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 28 epoches, the loss is: 143787.15625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 29 epoches, the loss is: 338477.15625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 30 epoches, the loss is: 552016.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 31 epoches, the loss is: 226012.40625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 31 epoches, the train acc. is: 0.19929166666666667"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 31 epoches, the val acc. is: 0.18666383520917393\n",
        "After 32 epoches, the loss is: 84499.65625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 33 epoches, the loss is: 93187.0625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 34 epoches, the loss is: 124218.265625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 35 epoches, the loss is: 195192.375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 36 epoches, the loss is: 93480.515625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 36 epoches, the train acc. is: 0.15575"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 36 epoches, the val acc. is: 0.14822679974516884\n",
        "After 37 epoches, the loss is: 29011.767578125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 38 epoches, the loss is: 143844.6875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 39 epoches, the loss is: 4774.08154296875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 40 epoches, the loss is: 147711.078125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 41 epoches, the loss is: 229955.84375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 41 epoches, the train acc. is: 0.16808333333333333"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 41 epoches, the val acc. is: 0.16436610745381186\n",
        "After 42 epoches, the loss is: 41245.26171875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 43 epoches, the loss is: 61784.70703125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 44 epoches, the loss is: 58684628992.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 45 epoches, the loss is: 11830205.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 46 epoches, the loss is: 1706396.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 46 epoches, the train acc. is: 0.196125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 46 epoches, the val acc. is: 0.20046719048630282\n",
        "After 47 epoches, the loss is: 1761523.75"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 48 epoches, the loss is: 356375.21875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 49 epoches, the loss is: 406394.5625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 50 epoches, the loss is: 1096076.5"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 51 epoches, the loss is: 316698.78125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 51 epoches, the train acc. is: 0.2365"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 51 epoches, the val acc. is: 0.2386918666383521\n",
        "After 52 epoches, the loss is: 1899551.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 53 epoches, the loss is: 1936673.5"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 54 epoches, the loss is: 66497.0078125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 55 epoches, the loss is: 496961.5625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 56 epoches, the loss is: 186637.03125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 56 epoches, the train acc. is: 0.13529166666666667"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 56 epoches, the val acc. is: 0.14631556593756637\n",
        "After 57 epoches, the loss is: 1102855.375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 58 epoches, the loss is: 245043.515625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 59 epoches, the loss is: 41648.10546875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 60 epoches, the loss is: 132608.359375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 61 epoches, the loss is: 101688.40625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 61 epoches, the train acc. is: 0.124875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 61 epoches, the val acc. is: 0.1342110851560841\n",
        "After 62 epoches, the loss is: 449821.65625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 63 epoches, the loss is: 36031.02734375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 64 epoches, the loss is: 1057436.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 65 epoches, the loss is: 39963.140625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 66 epoches, the loss is: 493968.46875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 66 epoches, the train acc. is: 0.11620833333333333"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 66 epoches, the val acc. is: 0.1276279464854534\n",
        "After 67 epoches, the loss is: 1073715.5"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 68 epoches, the loss is: 452774.625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 69 epoches, the loss is: 321189.46875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 70 epoches, the loss is: 61983.34375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 71 epoches, the loss is: 161431.5"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 71 epoches, the train acc. is: 0.13645833333333332"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 71 epoches, the val acc. is: 0.1471650031853897\n",
        "After 72 epoches, the loss is: 51216.96875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 73 epoches, the loss is: 21499.384765625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 74 epoches, the loss is: 27528.0390625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 75 epoches, the loss is: 43274.8671875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 76 epoches, the loss is: 56540.7109375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 76 epoches, the train acc. is: 0.126125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 76 epoches, the val acc. is: 0.13952006795497982\n",
        "After 77 epoches, the loss is: 33971.1484375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 78 epoches, the loss is: 55918.91796875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 79 epoches, the loss is: 29058.375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 80 epoches, the loss is: 193970.078125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 81 epoches, the loss is: 3157010.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 81 epoches, the train acc. is: 0.17408333333333334"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 81 epoches, the val acc. is: 0.16648970057337015\n",
        "After 82 epoches, the loss is: 2382268.25"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 83 epoches, the loss is: 786923.5625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 84 epoches, the loss is: 495068.625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 85 epoches, the loss is: 637232.0625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 86 epoches, the loss is: 533884.625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 86 epoches, the train acc. is: 0.174125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 86 epoches, the val acc. is: 0.1662773412614143\n",
        "After 87 epoches, the loss is: 28952.33984375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 88 epoches, the loss is: 242934.15625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 89 epoches, the loss is: 41477.8515625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 90 epoches, the loss is: 251132.84375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 91 epoches, the loss is: 161626.0625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 91 epoches, the train acc. is: 0.052333333333333336"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 91 epoches, the val acc. is: 0.04947971968570822\n",
        "After 92 epoches, the loss is: 75858.6640625"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 93 epoches, the loss is: 120884.6328125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 94 epoches, the loss is: 25102.908203125"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 95 epoches, the loss is: 127513.6171875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 96 epoches, the loss is: 100339.1796875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 96 epoches, the train acc. is: 0.05445833333333333"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 96 epoches, the val acc. is: 0.04905500106179656\n",
        "After 97 epoches, the loss is: 231912608.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 98 epoches, the loss is: 2665514.0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 99 epoches, the loss is: 744597.4375"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "After 100 epoches, the loss is: 955377.6875"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stderr",
       "text": [
        "/usr/local/lib/python3.5/dist-packages/torch/serialization.py:241: UserWarning: Couldn't retrieve source code for container of type FaceCNN. It won't be checked for correctness upon loading.\n",
        "  \"type \" + obj.__name__ + \". It won't be checked \"\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}